package com.lzx.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzx.article.entity.TwoSort;
import com.lzx.article.mapper.TwoSortMapper;
import com.lzx.article.service.TwoSortService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzx.common.utils.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lzx
 * @since 2023-01-11
 */
@Service
public class TwoSortServiceImpl extends ServiceImpl<TwoSortMapper, TwoSort> implements TwoSortService {
    @Resource
    private TwoSortMapper twoSortMapper;

    //获取使用量最多的十个标签
    @Override
    public R getTopTenLabel() {
        QueryWrapper<TwoSort> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id", 0).orderByDesc("usage_count");
        List<TwoSort> list = twoSortMapper.selectList(wrapper);
        return R.ok().data("list", list);
    }
}
